package org.gwt.grin.rebind.features;

import java.util.Formatter;

import org.gwt.grin.client.features.Fade;
import org.gwt.grin.rebind.SECommand;
import org.gwt.grin.rebind.SEFeature;
import org.gwt.grin.rebind.ShowBuilder;

public class SEFade extends SEModifier {

	private final SEFadeModel model = new SEFadeModel(this);

	final int[] fs;
	final int[] alphas;
	final int repeatFrame;
	final int loopCount;
	final SECommand[] endCommands;

	public SEFade(String name, int[] fs, int[] alphas, int repeatFrame,
			int loopCount, SECommand[] endCommands) {
		super(name);
		this.fs = fs;
		this.alphas = alphas;
		this.repeatFrame = repeatFrame;
		this.loopCount = loopCount;
		this.endCommands = endCommands;
	}

	public String write(ShowBuilder builder) {
		String cn = getClassName();
		Formatter formatter = new Formatter();
		formatter.format("new %s(\"%s\", %s, %s, %s)", cn, name,
				model.getVN(builder), getPart().getVN(builder),
				makeCommandsArray(builder, endCommands));
		return formatter.toString();
	}

	@Override
	protected String getClassName() {
		return Fade.class.getName();
	}

	public SEFeature getModel() {
		return model;
	}

}
